package com.itheima.list;

import java.util.ArrayList;
import java.util.List;

public class MyListDemo {
    public static void main(String[] args) {
        List<String> myList = new ArrayList<>();
        myList.add("张三");
        myList.add("李四");
        myList.add("王老五");
        myList.add("赵六");
        for (int i = 0; i < myList.size(); i++) {
            System.out.println(myList.get(i));
            if ("王老五".equals(myList.get(i))){
                myList.set(i,"王五");
            }
            System.out.println(myList.get(i));
        }
        myList.remove(myList.size()-1);
        System.out.println(myList);
    }
}
